<#include "/common/head.html"/>
<link rel="stylesheet" type="text/css" href="${basePath}/res/css/login.css">
<script type="text/javascript">
	if (self != top) { //主页不允许在iframe中
		top.window.location.reload();
	}
</script>
<div class="crm-register-bg">
	<div class="crm-register-form">
		<header class="crm-login1-header">
			<h1>欢迎登录电子合同管理系统</h1>
		</header>
		<form id="ff" class="easyui-form" method="post" action="zcurdHead/main"
			data-options="novalidate:true">
			<div class="crm-register-body crm-login1-body">
				<div class="crm-register-input-warpper">
					<input type="text" class="crm-register-input easyui-validatebox"
						data-options="required:true,validType:'length[2,20]'" value="admin" name="user_name"
						id="user_name" placeholder="请输入用户名" tabindex="1">
				</div>
				<div class="crm-register-input-warpper">
					<input type="password" class="crm-register-input easyui-validatebox"
						data-options="required:true" class="crm-register-input easyui-validatebox" value="123456"
						name="password" id="password" placeholder="请输入密码" tabindex="1" onfocus="">
				</div>
				<div class="crm-register-input-warpper"
					<#if isShowRandomCode==false>style="display: none;"</#if>
					> <input type="text" class="crm-register-input <#if isShowRandomCode>easyui-validatebox</#if>"
						data-options="required:true,validType:'length[4,4]'" name="randomCode" id="randomCode"
						placeholder="请输入识别码，点击图片可更换" tabindex="3"> <img id="codeImage" title="点击刷新验证码"
						src="login/randomCode" style="position: absolute; right: 20px; top: 4px; cursor: pointer;"
						onclick="this.src = 'login/randomCode?d=' + new Date().getTime();">
				</div>
			</div>
			<div class="crm-register-footer">
				<a href="javascript:login();" class="pg-btn-submit dinline-block " tabindex="3" act="login_btn">登
					录</a>
			</div>
		</form>
	</div>
</div>
<script type="text/javascript">
	$(function() {
		//获取焦点样式
		$("#ff :input").focus(function() {
			$(this).parent().addClass("actived");
		}).blur(function() {
			$(this).parent().removeClass("actived");
		});
	});

	//回车登陆
	document.onkeydown = function() {
		if (event.keyCode == 13) {
			login();
			return false;
		}
	}

	function login() {
		if ($("#ff").form('enableValidation').form('validate')) {
			var param = {
				"user_name" : $(":input[name='user_name']").val(),
				"password" : $(":input[name='password']").val(),
				"randomCode" : $(":input[name='randomCode']").val()
			}
			$.post("${basePath}/login/login", param, function(data) {
				if (data.result == "success") {
					$('#ff').submit();
					location.href = "main";
				} else {
					if (data.data) {
						$("#randomCode").parent().show();
						$("#randomCode").validatebox({
							required : true
						});
					}
					showWarnMsg(data.msg);
					$("#codeImage").click();
				}
			});
		}
	}
</script>
<#include "/common/foot.html"/>